FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ="Asia/Shanghai"

# 根据参数值执行不同操作
ARG APT_SOURCE=tsinghua
ARG TIMEZONE_SHANGHAI=Y

# 备份默认的软件源配置文件，并将其替换为清华源，最后更新软件源
RUN if [ "$APT_SOURCE" = "tsinghua" ]; then \
  cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak && \
  echo 'Types: deb' > /etc/apt/sources.list.d/ubuntu.sources && \
  echo 'URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/' >> /etc/apt/sources.list.d/ubuntu.sources && \
  echo 'Suites: noble noble-updates noble-backports noble-security' >> /etc/apt/sources.list.d/ubuntu.sources && \
  echo 'Components: main restricted universe multiverse' >> /etc/apt/sources.list.d/ubuntu.sources && \
  echo 'Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg' >> /etc/apt/sources.list.d/ubuntu.sources; \
  fi
#RUN apt-get update -y && apt-get upgrade -y

# 修改时区为 Asia/Shanghai
#RUN if [ "$TIMEZONE_SHANGHAI" = "Y" ]; then \
#      echo "tzdata tzdata/Areas select Asia" | debconf-set-selections && \
#      echo "tzdata tzdata/Zones/Asia select Shanghai" | debconf-set-selections && \
#      DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && \
#      echo -e "Current date:\n" >> /root/log && date >> /root/log; \
#    fi